<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>保险种类基础表 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="insTypInfo_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">
        <div class="fieldBox col_100">
            <div class="label">险种名称</div>
            <div class="field">
                <input name="typNm" id="typNm" type="text" class="ui-textbox" value="${insTypVO.typNm}"
                       validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">险种类型</div>
            <div class="field">
                <input name="typClsCd" id="typClsCd" data-value="${insTypVO.typClsCd}" placeholder="请选择" ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">保险父类</div>
            <div class="field">
                <input name="typPid" id="typPid" data-value="${insTypVO.typPid}" placeholder="请选择" ltype="combobox" validate="{required:false}">
            </div>
        </div>

        <div class="fieldBox col_100">
            <div class="label">是否默认显示</div>
            <div class="field">
                <select name="isDefVi" id="isDefVi" data-value="${insTypVO.isDefVi}"
                        validate="{required:true,select:true}">
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
                <span class="requiredSymbol">*</span>
            </div>
        </div>

        <div class="fieldBox col_100">
            <div class="label">险种标示</div>
            <div class="field">
                <input name="typNo" id="typNo" type="text" class="ui-textbox" value="${insTypVO.typNo}"
                       validate="{required:false}">
            </div>
        </div>

        <div class="fieldBox col_100">
            <div class="label">保险险种费率</div>
            <div class="field">
                <input name="typRate" id="typRate" type="text" class="ui-textbox" value="${insTypVO.typRate}"
                       validate="{required:false,number:true}">
            </div>
        </div>

        <div class="fieldBox col_100">
            <div class="label">备注</div>
            <div class="field">
                <textarea name="typRem" id="typRem" class="ui-textarea l-textarea" value="" cols="45"
                          rows="4">${insTypVO.typRem}</textarea>
            </div>
        </div>
    </div>

    <div class="btnsBox">
        <span id="saveInsTypInfo_Btn" class="sq-button sq-button-round">保存</span>
    </div>
</form>
<script>
    $(function () {
        var insTypInfoId = "${insTypVO.id}";//主键ID

        $("#typClsCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#typPid").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#insTypInfo_form").ligerForm({
            validate: true
        });
        liger.get("typClsCd").setData(${typClsCdList});
        liger.get("typPid").setData(${insTypCdList});
        /*保存*/
        $("#saveInsTypInfo_Btn").click(function (event) {
            var form = liger.get("insTypInfo_form");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            $.ligerDialog.hide();
            var _url;
            if (insTypInfoId == '') {//新增
                _url = '<%=path%>/insurance/insTypInfo/add.do';
            } else {//修改
                _url = '<%=path%>/insurance/insTypInfo/modify.do?id=' + insTypInfoId;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });


    });
</script>
</body>
</html>
